package ejb.dto;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


public class FlightDTO {
	
	private int id;
	private String company;
	private Date departureTime;
	private Date landingTime;
	private AirportDTO airport1;
	private AirportDTO airport2;
	private List<ReservationDTO> reservations1;
	private List<ReservationDTO> reservations2;
	
	private int airport1Id;
	private int airport2Id;
	
	private float price;
	private int remaining;
	private String extra;
	
	
	//GETTER AND SETTER
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCompany() {
		return company;
	}
	public void setCompany(String company) {
		this.company = company;
	}
	public Date getDepartureTime() {
		return departureTime;
	}
	public void setDepartureTime(Date departureTime) {
		this.departureTime = departureTime;
	}
	public Date getLandingTime() {
		return landingTime;
	}
	public void setLandingTime(Date landingTime) {
		this.landingTime = landingTime;
	}
	public AirportDTO getAirport1() {
		return airport1;
	}
	public void setAirport1(AirportDTO airport1) {
		this.airport1 = airport1;
	}
	public AirportDTO getAirport2() {
		return airport2;
	}
	public void setAirport2(AirportDTO airport2) {
		this.airport2 = airport2;
	}
	public List<ReservationDTO> getReservations1() {
		return reservations1;
	}
	public void setReservations1(List<ReservationDTO> reservations1) {
		this.reservations1 = reservations1;
	}
	public List<ReservationDTO> getReservations2() {
		return reservations2;
	}
	public void setReservations2(List<ReservationDTO> reservations2) {
		this.reservations2 = reservations2;
	}
	public int getAirport1Id() {
		return airport1Id;
	}
	public void setAirport1Id(int airport1Id) {
		this.airport1Id = airport1Id;
	}
	public int getAirport2Id() {
		return airport2Id;
	}
	public void setAirport2Id(int airport2Id) {
		this.airport2Id = airport2Id;
	}
	public int getRemaining() {
		return remaining;
	}
	public void setRemaining(int remaining) {
		this.remaining = remaining;
	}
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}

	
	//METHODS
	
	/**
	 * Return informations about a FlightDTO
	 * @return informations about a FlightDTO
	 */
	public String getDepartureInfo() {
		String dateString = new SimpleDateFormat("dd-MM-yyyy").format(departureTime);
		return "Volo con " + getCompany() + ", destinazione " + getAirport2().getName() + " (" + getAirport2().getLocation().getName() + ") in data " + dateString;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if(obj==null) {
			return false;
		}
		FlightDTO f = (FlightDTO) obj;
		if(this.id == f.getId()) {
			return true;
		}
		return false;
	}
	public String getExtra() {
		return extra;
	}
	public void setExtra(String extra) {
		this.extra = extra;
	}
	
}
